<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>搜索 - 手机客户端</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/buttons.css" />
<script src="js/jquery.js"></script>
<script src="js/touchslider.js"></script>
<script src="js/jquery.global.js"></script>
<script type="text/javascript">
	var getColor = function(num){
		switch(parseInt(num)){
			case 1:return " blue";break;
			case 2:return " green";break;
			default: return "";
		}
	};
	$(function($){
		var $loadAjax = new $.LoadAjax({
			renderTarget : "#search-tag ul",
			fn : function(obj,data,mask){
				if(data.length==0){
					$(mask).remove();
				}else{
					for(var i in data){
						$(obj).append('<li><a class="button orange'+getColor(data[i].color)+'" href="javascript:;">'+data[i].name+'</a></li>');
					}
					$searcher.init()
				}
			},
			url : requestPath+"/websamp/pubapi/mobile/appHotKey"
		});
		//alert(index);
		$loadAjax.init();
		$loadAjax.loadAppList();
		var flag;
		var $searcher = new $.Searcher({
			fn : function(appName,modFlag,loadFlag){
				var $loadAjax = new $.LoadAjax({
					renderTarget : ".wrap #appList ul",
					fn : function(obj,dataSet,mask,appName){
						data = dataSet.appInstallItemList;
						//alert($(obj).has("li").length);
						if(loadFlag){
							$(obj).empty();
						}
						if(modFlag){
							$(".list").is(":hidden")?slideTab():null;
							modFlag = false;
						}
						var dataSize=dataSet.dataSize;
						$(obj).prev().find("span:first").html(appName).next().html(dataSize);
						if(data.length==0){
							$(mask).remove();
							loadFlag?$(obj).html('<li class="none">根据蜂帮手算法规则，部分搜索结果未能显示。</li>'):null;
							$(window).unbind("scroll");
						}else{
							//loadFlag=dataSize>data.length?true:false;
							for(var i in data){
								$(obj).append('<li data-appId="'+data[i].appId+'" data-id="'+data[i].id+'"><dl><dd><img src="'+requestPicPath+data[i].picPath+'" /></dd><dt><strong>'+data[i].name+'</strong>'+(data[i].appVersion==null?'':'<span>版本:'+data[i].appVersion+'</span>|')+'<span>大小:'+data[i].size+'MB</span></dt><dd><button data-url="'+requestPicPath+data[i].url+'">免费下载</button>'+data[i].downloadTimes+'次</dd></dl></li>');
							}
							pageSize=dataSet.pageSize;
							var offset=dataSet.offset+1;
							var pageNum=Math.ceil(dataSize/pageSize);
							pagenow=Math.ceil(offset/pageSize);
							loadFlag = false;
						}
					},
					url : requestPath+"/websamp/pubapi/mobile/loadFbsApp",
					picPath : requestPicPath,
					pageSize : 12,
					appName : appName,
					srcollingWrap : window
				});
				flag?null:$loadAjax.init();
				flag = true;
				$loadAjax.loadAppList();
				$loadAjax.scrollLoading();
			}
		});
		new $.Switchover().init();
		new $.Download({obj : ".wrap #appList ul li dl dd button"}).init();
		$("#search-tag ul li:eq(3)").find("a").addClass("blue");
		$("#search-tag ul li:eq(6)").find("a").addClass("green");
	});
</script>
</head>
<body>
<div class="wrap">
  <div id="search">
    <input type="text" placeholder="浏览器" /><input type="submit" value="" />
  </div>
  <div id="search-tag" class="panel tag">
    <ul></ul>
  </div>
  <div id="appList" class="panel list none">
  <p class="result"><strong>搜索</strong>“<span></span>”共找到<span></span>款应用，[<a href="javascript:;">返回</a>]</p>
    <ul>
    </ul>
  </div>
</div>
</body>
</html>